package cn.dzhang.spring.boot.remoting;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter;

import cn.dzhang.spring.boot.service.DeviceCategoryService;
import cn.dzhang.spring.boot.service.DeviceService;
import cn.dzhang.spring.boot.service.DeviceTypeService;
import cn.dzhang.spring.boot.service.RoleService;
import cn.dzhang.spring.boot.service.UserService;

@Configuration
public class RemotingSetting {

	@Autowired
	private UserService userService;
	@Autowired
	private RoleService roleService;
	@Autowired
	private DeviceService deviceService;
	@Autowired
	private DeviceCategoryService deviceCategoryService;
	@Autowired
	private DeviceTypeService deviceTypeService;

	@Bean(name = "/UserService")
	public HttpInvokerServiceExporter userService() {
		HttpInvokerServiceExporter exporter = new HttpInvokerServiceExporter();
		exporter.setService(userService);
		exporter.setServiceInterface(UserService.class);
		return exporter;
	}
	
	@Bean(name = "/RoleService")
	public HttpInvokerServiceExporter roleService() {
		HttpInvokerServiceExporter exporter = new HttpInvokerServiceExporter();
		exporter.setService(roleService);
		exporter.setServiceInterface(RoleService.class);
		return exporter;
	}
	@Bean(name = "/DeviceService")
	public HttpInvokerServiceExporter deviceService() {
		HttpInvokerServiceExporter exporter = new HttpInvokerServiceExporter();
		exporter.setService(deviceService);
		exporter.setServiceInterface(DeviceService.class);
		return exporter;
	}
	@Bean(name = "/DeviceCategoryService")
	public HttpInvokerServiceExporter deviceCategoryService() {
		HttpInvokerServiceExporter exporter = new HttpInvokerServiceExporter();
		exporter.setService(deviceCategoryService);
		exporter.setServiceInterface(DeviceCategoryService.class);
		return exporter;
	}
	@Bean(name = "/DeviceTypeService")
	public HttpInvokerServiceExporter deviceTypeService() {
		HttpInvokerServiceExporter exporter = new HttpInvokerServiceExporter();
		exporter.setService(deviceTypeService);
		exporter.setServiceInterface(DeviceTypeService.class);
		return exporter;
	}
}
